{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# dp\n",
    "\n",
    "## 介绍\n",
    "针对A股因子研究和交易分析场景，提供了常用的小工具，如查询历史的交易日，历史的行业分类表等"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import warnings\n",
    "warnings.filterwarnings('ignore')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('username: 18566262672', '0,')"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_config = {\n",
    "\"remote.data.address\": \"tcp://data.tushare.org:8910\",\n",
    "\"remote.data.username\": \"18566262672\",\n",
    "\"remote.data.password\": \"eyJhbGciOiJIUzI1NiJ9.eyJjcmVhdGVfdGltZSI6IjE1MTI3MDI3NTAyMTIiLCJpc3MiOiJhdXRoMCIsImlkIjoiMTg1NjYyNjI2NzIifQ.O_-yR0zYagrLRvPbggnru1Rapk4kiyAzcwYt2a3vlpM\"\n",
    "}\n",
    "\n",
    "from jaqs_fxdayu.data import DataApi\n",
    "\n",
    "api = DataApi(data_config[\"remote.data.address\"]) # 传入连接到的远端数据服务器的tcp地址\n",
    "api.login(username=data_config[\"remote.data.username\"],\n",
    "          password=data_config[\"remote.data.password\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## trade_days\n",
    "- ` jaqs_fxdayu.util.dp.trade_days(api, start, end) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 返回起止日期间的交易日\n",
    "\n",
    "**参数:**\n",
    "\n",
    "|字段|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|api |是| jaqs.data.DataApi |jaqs.data.DataApi|\n",
    "|start |是|int |开始日期|\n",
    "|end |是|int |结束日期|\n",
    "\n",
    "**返回:**\n",
    "\n",
    "起止日期间的交易日\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Int64Index([20170103, 20170104, 20170105, 20170106, 20170109, 20170110,\n",
       "            20170111, 20170112, 20170113, 20170116,\n",
       "            ...\n",
       "            20171218, 20171219, 20171220, 20171221, 20171222, 20171225,\n",
       "            20171226, 20171227, 20171228, 20171229],\n",
       "           dtype='int64', name='trade_date', length=244)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from jaqs_fxdayu.util.dp import trade_days\n",
    "trade_days(api, 20170101, 20180101)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## index_cons\n",
    "- ` jaqs_fxdayu.util.dp.index_cons(api, index_code, start, end) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 获得某个指数起止时间段的历史成分股信息\n",
    "\n",
    "**参数:**\n",
    "\n",
    "|字段|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|api |是| jaqs.data.DataApi |jaqs.data.DataApi|\n",
    "|index_code |是| str |指数代码|\n",
    "|start |是|int |开始日期|\n",
    "|end |是|int |结束日期|\n",
    "\n",
    "**返回:**\n",
    "\n",
    "某个指数起止时间段的历史成分股信息\n",
    "\n",
    "- 其中 in_date:纳入该指数的时间；out_date:从该指数移除的时间\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>in_date</th>\n",
       "      <th>index_code</th>\n",
       "      <th>out_date</th>\n",
       "      <th>symbol</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>20050408</td>\n",
       "      <td>000300.SH</td>\n",
       "      <td>99999999</td>\n",
       "      <td>000001.SZ</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20050408</td>\n",
       "      <td>000300.SH</td>\n",
       "      <td>99999999</td>\n",
       "      <td>000002.SZ</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>20161212</td>\n",
       "      <td>000300.SH</td>\n",
       "      <td>99999999</td>\n",
       "      <td>000008.SZ</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>20050408</td>\n",
       "      <td>000300.SH</td>\n",
       "      <td>20171208</td>\n",
       "      <td>000009.SZ</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>20140616</td>\n",
       "      <td>000300.SH</td>\n",
       "      <td>20170609</td>\n",
       "      <td>000027.SZ</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    in_date index_code  out_date     symbol\n",
       "0  20050408  000300.SH  99999999  000001.SZ\n",
       "1  20050408  000300.SH  99999999  000002.SZ\n",
       "2  20161212  000300.SH  99999999  000008.SZ\n",
       "3  20050408  000300.SH  20171208  000009.SZ\n",
       "4  20140616  000300.SH  20170609  000027.SZ"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from jaqs_fxdayu.util.dp import index_cons\n",
    "index_cons(api, \"000300.SH\", 20170101, 20170501).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## daily_index_cons\n",
    "- ` jaqs_fxdayu.util.dp.daily_index_cons(api, index_code, start, end) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 指定起止时间段，成分股是否还在某指数当中\n",
    "\n",
    "**参数:**\n",
    "\n",
    "|字段|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|api |是| jaqs.data.DataApi |jaqs.data.DataApi|\n",
    "|index_code |是| str |指数代码|\n",
    "|start |是|int |开始日期|\n",
    "|end |是|int |结束日期|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601933.SH</th>\n",
       "      <th>601939.SH</th>\n",
       "      <th>601958.SH</th>\n",
       "      <th>601985.SH</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170103</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>...</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170104</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>...</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170105</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>...</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170106</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>...</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170109</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>...</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 301 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            000001.SZ  000002.SZ  000008.SZ  000009.SZ  000027.SZ  000039.SZ  \\\n",
       "trade_date                                                                     \n",
       "20170103         True       True       True       True       True       True   \n",
       "20170104         True       True       True       True       True       True   \n",
       "20170105         True       True       True       True       True       True   \n",
       "20170106         True       True       True       True       True       True   \n",
       "20170109         True       True       True       True       True       True   \n",
       "\n",
       "            000060.SZ  000061.SZ  000063.SZ  000069.SZ    ...      601933.SH  \\\n",
       "trade_date                                                ...                  \n",
       "20170103         True       True       True       True    ...           True   \n",
       "20170104         True       True       True       True    ...           True   \n",
       "20170105         True       True       True       True    ...           True   \n",
       "20170106         True       True       True       True    ...           True   \n",
       "20170109         True       True       True       True    ...           True   \n",
       "\n",
       "            601939.SH  601958.SH  601985.SH  601988.SH  601989.SH  601998.SH  \\\n",
       "trade_date                                                                     \n",
       "20170103         True       True       True       True       True       True   \n",
       "20170104         True       True       True       True       True       True   \n",
       "20170105         True       True       True       True       True       True   \n",
       "20170106         True       True       True       True       True       True   \n",
       "20170109         True       True       True       True       True       True   \n",
       "\n",
       "            603000.SH  603885.SH  603993.SH  \n",
       "trade_date                                   \n",
       "20170103         True       True       True  \n",
       "20170104         True       True       True  \n",
       "20170105         True       True       True  \n",
       "20170106         True       True       True  \n",
       "20170109         True       True       True  \n",
       "\n",
       "[5 rows x 301 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from jaqs_fxdayu.util.dp import daily_index_cons\n",
    "daily_index_cons(api, \"000300.SH\", 20170101, 20170501).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## st_status\n",
    "- ` jaqs_fxdayu.util.dp.st_status(api, symbol, start, end) `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 指定起止时间段，股票是否进入异常状态（含st,*st,退市等）\n",
    "- 注:从未进入过异常状态的股票不会在返回值里\n",
    "- 注:该方法目前只有在fxdayu数据源下才可访问到（非公开接口）\n",
    "\n",
    "**参数:**\n",
    "\n",
    "|字段|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|api |是| jaqs.data.DataApi |jaqs.data.DataApi|\n",
    "|symbol |是| str |股票代码,以\",\"隔开|\n",
    "|start |是|int |开始日期|\n",
    "|end |是|int |结束日期|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>000003.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170103</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170104</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170105</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170106</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170109</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            000003.SZ  000008.SZ\n",
       "trade_date                      \n",
       "20170103          1.0        0.0\n",
       "20170104          1.0        0.0\n",
       "20170105          1.0        0.0\n",
       "20170106          1.0        0.0\n",
       "20170109          1.0        0.0"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from jaqs_fxdayu.util.dp import st_status\n",
    "st_status(api, \"000001.SZ,000003.SZ,000008.SZ\", 20170101, 20170501).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## daily_sec_industry\n",
    "- ` jaqs_fxdayu.util.dp.daily_sec_industry(api, symbol, start, end, source=\"sw\", value=\"industry1_code\") `\n",
    "\n",
    "**简要描述：**\n",
    "\n",
    "- 指定起始时间段，查询某一系列股票在该时间段下的行业分类信息\n",
    "\n",
    "**参数:**\n",
    "\n",
    "|字段|必选|类型|说明|\n",
    "|:----    |:---|:----- |-----   |\n",
    "|api |是| jaqs.data.DataApi |jaqs.data.DataApi|\n",
    "|symbol |是| str |股票代码，用\",\"隔开。如\"600000.SH,000001.SZ\"|\n",
    "|start |是|int |开始日期|\n",
    "|end |是|int |结束日期|\n",
    "|source |否|str |行业分类标准，目前仅支持\"sw\"(申万),\"zz\"(中证),\"zjh\"（证监会）,默认\"sw\"|\n",
    "|value |否|str |行业等级，形式可为\"industry?_code\"(行业编码)/\"industry?_name\"(行业名称)。其中\"?\"可为1,2,3,4,分别代表1-4个行业等级。申万支持1-4,中证支持1-2。默认为industry1_code|\n",
    "\n",
    "**示例：**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>000001.SZ</th>\n",
       "      <th>000002.SZ</th>\n",
       "      <th>000008.SZ</th>\n",
       "      <th>000009.SZ</th>\n",
       "      <th>000027.SZ</th>\n",
       "      <th>000039.SZ</th>\n",
       "      <th>000060.SZ</th>\n",
       "      <th>000061.SZ</th>\n",
       "      <th>000063.SZ</th>\n",
       "      <th>000069.SZ</th>\n",
       "      <th>...</th>\n",
       "      <th>601988.SH</th>\n",
       "      <th>601989.SH</th>\n",
       "      <th>601992.SH</th>\n",
       "      <th>601997.SH</th>\n",
       "      <th>601998.SH</th>\n",
       "      <th>603000.SH</th>\n",
       "      <th>603160.SH</th>\n",
       "      <th>603858.SH</th>\n",
       "      <th>603885.SH</th>\n",
       "      <th>603993.SH</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20170925</th>\n",
       "      <td>金融业</td>\n",
       "      <td>房地产业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>综合</td>\n",
       "      <td>电力、热力、燃气及水生产和供应业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>租赁和商务服务业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>水利、环境和公共设施管理业</td>\n",
       "      <td>...</td>\n",
       "      <td>金融业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>金融业</td>\n",
       "      <td>金融业</td>\n",
       "      <td>信息传输、软件和信息技术服务业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>交通运输、仓储和邮政业</td>\n",
       "      <td>采矿业</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170926</th>\n",
       "      <td>金融业</td>\n",
       "      <td>房地产业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>综合</td>\n",
       "      <td>电力、热力、燃气及水生产和供应业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>租赁和商务服务业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>水利、环境和公共设施管理业</td>\n",
       "      <td>...</td>\n",
       "      <td>金融业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>金融业</td>\n",
       "      <td>金融业</td>\n",
       "      <td>信息传输、软件和信息技术服务业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>交通运输、仓储和邮政业</td>\n",
       "      <td>采矿业</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170927</th>\n",
       "      <td>金融业</td>\n",
       "      <td>房地产业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>综合</td>\n",
       "      <td>电力、热力、燃气及水生产和供应业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>租赁和商务服务业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>水利、环境和公共设施管理业</td>\n",
       "      <td>...</td>\n",
       "      <td>金融业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>金融业</td>\n",
       "      <td>金融业</td>\n",
       "      <td>信息传输、软件和信息技术服务业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>交通运输、仓储和邮政业</td>\n",
       "      <td>采矿业</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170928</th>\n",
       "      <td>金融业</td>\n",
       "      <td>房地产业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>综合</td>\n",
       "      <td>电力、热力、燃气及水生产和供应业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>租赁和商务服务业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>水利、环境和公共设施管理业</td>\n",
       "      <td>...</td>\n",
       "      <td>金融业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>金融业</td>\n",
       "      <td>金融业</td>\n",
       "      <td>信息传输、软件和信息技术服务业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>交通运输、仓储和邮政业</td>\n",
       "      <td>采矿业</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20170929</th>\n",
       "      <td>金融业</td>\n",
       "      <td>房地产业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>综合</td>\n",
       "      <td>电力、热力、燃气及水生产和供应业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>租赁和商务服务业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>水利、环境和公共设施管理业</td>\n",
       "      <td>...</td>\n",
       "      <td>金融业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>金融业</td>\n",
       "      <td>金融业</td>\n",
       "      <td>信息传输、软件和信息技术服务业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>制造业</td>\n",
       "      <td>交通运输、仓储和邮政业</td>\n",
       "      <td>采矿业</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 330 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           000001.SZ 000002.SZ 000008.SZ 000009.SZ         000027.SZ  \\\n",
       "trade_date                                                             \n",
       "20170925         金融业      房地产业       制造业        综合  电力、热力、燃气及水生产和供应业   \n",
       "20170926         金融业      房地产业       制造业        综合  电力、热力、燃气及水生产和供应业   \n",
       "20170927         金融业      房地产业       制造业        综合  电力、热力、燃气及水生产和供应业   \n",
       "20170928         金融业      房地产业       制造业        综合  电力、热力、燃气及水生产和供应业   \n",
       "20170929         金融业      房地产业       制造业        综合  电力、热力、燃气及水生产和供应业   \n",
       "\n",
       "           000039.SZ 000060.SZ 000061.SZ 000063.SZ      000069.SZ    ...     \\\n",
       "trade_date                                                           ...      \n",
       "20170925         制造业       制造业  租赁和商务服务业       制造业  水利、环境和公共设施管理业    ...      \n",
       "20170926         制造业       制造业  租赁和商务服务业       制造业  水利、环境和公共设施管理业    ...      \n",
       "20170927         制造业       制造业  租赁和商务服务业       制造业  水利、环境和公共设施管理业    ...      \n",
       "20170928         制造业       制造业  租赁和商务服务业       制造业  水利、环境和公共设施管理业    ...      \n",
       "20170929         制造业       制造业  租赁和商务服务业       制造业  水利、环境和公共设施管理业    ...      \n",
       "\n",
       "           601988.SH 601989.SH 601992.SH 601997.SH 601998.SH        603000.SH  \\\n",
       "trade_date                                                                      \n",
       "20170925         金融业       制造业       制造业       金融业       金融业  信息传输、软件和信息技术服务业   \n",
       "20170926         金融业       制造业       制造业       金融业       金融业  信息传输、软件和信息技术服务业   \n",
       "20170927         金融业       制造业       制造业       金融业       金融业  信息传输、软件和信息技术服务业   \n",
       "20170928         金融业       制造业       制造业       金融业       金融业  信息传输、软件和信息技术服务业   \n",
       "20170929         金融业       制造业       制造业       金融业       金融业  信息传输、软件和信息技术服务业   \n",
       "\n",
       "           603160.SH 603858.SH    603885.SH 603993.SH  \n",
       "trade_date                                             \n",
       "20170925         制造业       制造业  交通运输、仓储和邮政业       采矿业  \n",
       "20170926         制造业       制造业  交通运输、仓储和邮政业       采矿业  \n",
       "20170927         制造业       制造业  交通运输、仓储和邮政业       采矿业  \n",
       "20170928         制造业       制造业  交通运输、仓储和邮政业       采矿业  \n",
       "20170929         制造业       制造业  交通运输、仓储和邮政业       采矿业  \n",
       "\n",
       "[5 rows x 330 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from jaqs_fxdayu.util.dp import daily_sec_industry\n",
    "symbol_id = index_cons(api, \"000300.SH\", 20170501, 20171001,)[\"symbol\"].dropna()\n",
    "symbols = \",\".join(symbol_id)\n",
    "group = daily_sec_industry(api, symbols, 20170501, 20171001, source='zjh', value=\"industry1_name\")\n",
    "group.tail()"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [conda env:IIA]",
   "language": "python",
   "name": "conda-env-IIA-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
